
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>xhr传递参数</title>
</head>
<body>
    <p class="city">

    </p>

    <script>
        

         
        //  * 1;创建Promise对象
        //  * 2：执行XHR异步代码 获取省份列表数据
        //  * 3：关联成功或失败函数
         


        // 创建对象
        const  xhr = new XMLHttpRequest()

        xhr.open("get","http://hmajax.itheima.net/api/city?pname=河南省")

        xhr.addEventListener("loadend",function () {
            console.log(xhr.response);
            const data = JSON.parse(xhr.response)
            document.querySelector('.city').innerHTML = data.list.join("<br />")
            
        })

        xhr.send()

    </script>

</body>
</html>